<template>
	<view class="p20">
		<view class="flex flex-col row-center mt84 px40" v-if="!list.length">
			<image src="/static/img/my/addPatient.png" class="h360 w360" mode=""></image>
			<view class="fs30 color-B7B5B5 mt36 ">您还未添加就诊人~</view>
		</view>
		<view v-for="(item,index) in list" :key="index" @click="set(item)" class="bg-fff p20 mb20 radius20">
			<view class="flex row-between border-b pb22">
				<view class="">
					<view class="flex">
						<view class="">{{item.name}}</view>
						<image src="/static/img/my/girl.png" v-if="item.sex==2" class="h36 w36 ml16" mode="">
						</image>
						<image src="/static/img/my/boy.png" v-if="item.sex==1" class="h36 w36 ml16" mode=""></image>
					</view>
					<view class="color-999 fs26 mt14">年龄：{{item.age}}</view>
				</view>
				<view class="color-999 fs26 mt14">{{item.card_no}}</view>
			</view>
			<view class="fs28 color-666 flex fs24 mt30">
				<view class="flex" @click.stop="$u.route('/pages/my/addPatient/addPatient',item)">
					<image src="/static/img/my/edit.png" class="h32 w32" mode=""></image>
					<view class="color-fs ml14">修改</view>
				</view>
				<view class="flex ml60" @click.stop="del(item)">
					<image src="/static/img/my/delete.png" class="h32 w32 " mode=""></image>
					<view class="color-zs ml14">删除</view>
				</view>
			</view>
		</view>
		<view class="h120"></view>
		<view class="pf bottom0 left0 w-max p20">
			<view class="bg-zs color-fff h84 radius12 flex row-center"
				@click="$u.route('/pages/my/addPatient/addPatient')">
				+ 添加就诊人
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: ''
			};
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				this.$request('/member/my/patientList').then(res => {
					this.list = res.data.data
				})
			},
			set(item) {
				if (!this.$params.sel) return
				uni.$emit('set_patient', item)
				this.$navBack()
			},
			del(item) {
				this.$showModal('删除').then(res => {
					this.$request('/member/my/patientDel', {
						id: item.id
					}).then(res => {
						this.$msg(res.msg)
						this.getList()
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	// page {
	// 	background-color: #FFFFFF;
	// }
</style>
